package task5;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Player {
    private String name;
    private List<Card> cards;

    public Player(String name) {
        this.name = name;
        this.cards = new ArrayList<>();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Card> getCards() {
        return cards;
    }

    public void setCards(List<Card> cards) {
        this.cards = cards;
    }

    public void dealCards(Card card){
        cards.add(card);
    }

    public void showCards(){
        Collections.sort(cards, new Comparator<Card>(){
            @Override
            public int compare(Card o1, Card o2) {
                return o1.getOrder() - o2.getOrder();
            }
        });
        System.out.println(name + "玩家手中的牌为：" + cards);
    }
}
